[SPARK-57870][ML][PYTHON] Apply HasIntermediateStorageLevel to tree ensemble estimators (GBT, RandomForest)#57206
Open
maoli67660 wants to merge 1 commit into
Open
[SPARK-57870][ML][PYTHON] Apply HasIntermediateStorageLevel to tree ensemble estimators (GBT, RandomForest)#57206maoli67660 wants to merge 1 commit into
maoli67660 wants to merge 1 commit into
Conversation
…nsemble estimators (GBT, RandomForest) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This is a sub-task of SPARK-47103, which aims to make the storage level of MLlib's intermediate datasets configurable. It applies the shared param
HasIntermediateStorageLevel(added in SPARK-57860, first reused in SPARK-57910) to the tree ensemble estimators:RandomForestClassifier,RandomForestRegressor,GBTClassifier, andGBTRegressor.TreeEnsembleParamsnow extendsHasIntermediateStorageLevel, so all four estimators (and their models, which share the params traits) expose the param; each estimator gains asetIntermediateStorageLevelsetter and logs the param viaInstrumentation.storageLevelparameter defaulting toStorageLevel.MEMORY_AND_DISK(so the oldspark.mllibAPI andDecisionTreeClassifier/DecisionTreeRegressor, which reach the same code, are unchanged):RandomForest.run/RandomForest.runBagged: thebagged tree pointsRDD and the node-id-cachePeriodicRDDCheckpointer.GradientBoostedTrees.run/runWithValidation/boost: thebinned tree points,firstCounts,labelWithCounts, and validationTreePointRDDs, plus the two prediction-errorPeriodicRDDCheckpointers._TreeEnsembleParamsmixes inHasIntermediateStorageLevel, and the four estimators gainsetIntermediateStorageLevel, mirroring the Scala hierarchy so Scala/Python param parity is preserved for both estimators and models.Why are the changes needed?
The tree ensemble trainers persist several intermediate RDDs internally with a hardcoded
MEMORY_AND_DISKlevel. These datasets are created inside the algorithm, so users have no way to change their storage level, unlike the inputDataFramewhich they can cache themselves. Making this configurable (e.g.DISK_ONLY) improves resilience to executor loss: since SPARK-27677 the External Shuffle Service can serve disk-persisted cached blocks.ALS(SPARK-57910) andKMeans(SPARK-57860) already expose the same param; this PR extends it to the tree ensembles.Does this PR introduce any user-facing change?
Yes.
RandomForestClassifier,RandomForestRegressor,GBTClassifier, andGBTRegressor(Scala and PySpark) gain a new expert paramintermediateStorageLeveland asetIntermediateStorageLevelsetter.The default is
"MEMORY_AND_DISK", so behavior is unchanged unless the user sets it.Before (no way to change the intermediate storage level):
After:
How was this patch tested?
"NONE"and non-existent levels) are rejected.RandomForestClassifierSuiteandGBTRegressorSuiteadd an end-to-end test (modeled afterALSStorageSuite) that fits withintermediateStorageLevel = "DISK_ONLY"and verifies via aSparkListenerthat the intermediate RDDs were actually persisted at that level, covering both theRandomForestandGradientBoostedTreescode paths.ml.tree.impl.RandomForestSuite/GradientBoostedTreesSuitepass (22/22) locally.pyspark.ml.tests.test_param(test_java_params), which passes locally.dev/mimareports no binary compatibility problems; noMimaExcludesentries are needed (the param members are new, unlike the ALS case in SPARK-57910).Was this patch authored or co-authored using generative AI tooling?
Cooperate with: Claude Code (Fable 5)